home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 11,000 to 11,999 / 11000.zip / AOLDLs / Programmieren [Delphi - Units] / TOMAPI95_ Filetool Unit für Delp / TOMAPI95.pas < prev   
Encoding:
Pascal/Delphi Source File  |  2014-12-20  |  4.9 KB  |  154 lines

  1. {******************************************************************
  2. * Unit         :  TomApi95.pas                                    *
  3. * Desc.        :  API Tools f. Delphi II / Win 95                 *
  4. * Author       :  Thomas Hⁿhn                                     *
  5. * Created      :  09.10.1997                                      *
  6. * Target       :  Delphi II (maybe also III not testet yet        *
  7. * Copyright    :  ⌐1997 Thomas Hⁿhn                               *
  8. * E-Mail Adress of the Author is thomashueh@aol.com               *
  9. *                             or tomh@supernews.com               *
  10. *******************************************************************
  11.  
  12.   Feel free to use this unit in you own programms. But you are not
  13.   allowed to sell it as your own work!! If you share this unit then
  14.   share it in one part!!! The author is not reponsible for any damage
  15.   on your system - use it or let it!! Don't worry it's not a virus..LOL
  16.   For Comments feel free to send me a mail. If you made usefull changes
  17.   please send them to me. The Source life!!
  18.   And don't forget DELPHI RULES!
  19.  
  20.   Tom.
  21.  
  22.  
  23. ...........................................................................
  24. History:
  25. ░░░░░░░
  26.    09.10.1997: started with FileFunctions
  27.    09.10.1997: to early to sleep also added ExecFile 11:59 p.m.
  28. ...........................................................................
  29. }
  30.  
  31.  
  32. unit TomApi95;
  33.  
  34. interface
  35. uses  Windows,Classes,SHELLAPI;
  36.  
  37. //------------File Copy/Move/Delete Functions only Windows 95 not NT!! ---------
  38. // aHandle:Handle of Window (your Form only type in Handle)
  39. // ASource:TString filled with Files
  40. // ADest:DestinationDirectory
  41. // Returns false if User aborted
  42. // Note: aHandle is needed to allocate the API-PROGRESSDIALOG
  43. // Note2: Delete deletes really it don't move to the Thrash-Bin!!
  44. // Example: ShFileCopy(Handle,DirecoryListbox1.Items,'C:\TMP')
  45. Function ShFileCopy(aHandle:HWND;ASource:TStrings;ADest:String):boolean;
  46. Function ShFileMove(aHandle:HWND;ASource:TStrings;ADest:String):boolean;
  47. Function ShFileDelete(aHandle:HWND;ASource:TStrings):boolean;
  48.  
  49.  
  50. //------------------File Exec Function Windows 95 and NT!! -----------------
  51. // aCmdLine : File to Exec
  52. // AHide    : Hide Window
  53. // aWait    : Wait for End of Application
  54. // Returns false if execute fails
  55. function fileExec(const aCmdLine: String; aHide, aWait: Boolean): Boolean;
  56.  
  57.  
  58. //----------------------------- IMPLEMANTATION-------------------------------
  59. implementation
  60. var
  61.  shellinfo : TSHFILEOPSTRUCT ;
  62.  
  63. //------------File Copy Function only Windows 95 not NT!! ---------
  64. Function ShFileCopy(aHandle:HWND;ASource:TStrings;ADest:String):boolean;
  65.  var i:integer;
  66.      Files:string;
  67. begin
  68.  
  69.  Files:='';
  70.  for i:=0 to ASource.count-1 do
  71.     Files:=Files+ASource[i]+#0;
  72.  Files:=Files+#0;
  73.  With shellInfo do
  74.   begin
  75.     wnd:=aHandle;
  76.     wfunc:=FO_COPY;
  77.     pFrom:=PChar(files);
  78.     pTo:=PChar(ADest);
  79.     Result:=  ShellInfo.fAnyOperationsAborted ;
  80.    end;
  81.  SHFileOperation(shellInfo);
  82. end;
  83.  
  84. //------------File Move Function only Windows 95 not NT!! ---------
  85. Function ShFileMove(aHandle:HWND;ASource:TStrings;ADest:String):boolean;
  86.  var i:integer;
  87.      Files:string;
  88. begin
  89.  
  90.  Files:='';
  91.  for i:=0 to ASource.count-1 do
  92.     Files:=Files+ASource[i]+#0;
  93.  Files:=Files+#0;
  94.  With shellInfo do
  95.   begin
  96.     wnd:=aHandle;
  97.     wfunc:=FO_MOVE;
  98.     pFrom:=PChar(files);
  99.     pTo:=PChar(ADest);
  100.     Result:= not ShellInfo.fAnyOperationsAborted ;
  101.    end;
  102.  SHFileOperation(shellInfo);
  103. end;
  104.  
  105. //------------File Delete Function only Windows 95 not NT!! ---------
  106. Function ShFileDelete(aHandle:HWND;ASource:TStrings):boolean;
  107.  var i:integer;
  108.      Files:string;
  109. begin
  110.  Files:='';
  111.  for i:=0 to ASource.count-1 do
  112.     Files:=Files+ASource[i]+#0;
  113.  Files:=Files+#0;
  114.  With shellInfo do
  115.   begin
  116.     wnd:=aHandle;
  117.     wfunc:=FO_DELETE;
  118.     pFrom:=PChar(files);
  119.     pTo:=nil;
  120.     Result:= not ShellInfo.fAnyOperationsAborted ;
  121.    end;
  122.  SHFileOperation(shellInfo);
  123. end;
  124.  
  125. //------------------File Exec Function Windows 95 and NT!! -----------------
  126. function fileExec(const aCmdLine: String; aHide, aWait: Boolean): Boolean;
  127. var
  128.   StartupInfo : TStartupInfo;
  129.   ProcessInfo : TProcessInformation;
  130. begin
  131.   FillChar(StartupInfo, SizeOf(TStartupInfo), 0);
  132.   with StartupInfo do
  133.   begin
  134.     cb:= SizeOf(TStartupInfo);
  135.     dwFlags:= STARTF_USESHOWWINDOW or STARTF_FORCEONFEEDBACK;
  136.     if aHide then wShowWindow:= SW_HIDE
  137.              else wShowWindow:= SW_SHOWNORMAL;
  138.   end;
  139.  
  140.   Result := CreateProcess(nil,PChar(aCmdLine), nil, nil, False,
  141.                NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo);
  142.   if aWait then
  143.      if Result then
  144.      begin
  145.        WaitForInputIdle(ProcessInfo.hProcess, INFINITE);
  146.        WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
  147.      end;
  148. end;
  149.  
  150.  
  151. //---------------------- End of File....for now -----------------------------
  152. end.
  153.  
  154.